define(function(require){
    var main = require('/modules/js/seajs/main.js');
    var m = new main();
    function Cont(){
        this.Fun._init();
    }
    Cont.prototype.Fun = {
        page:{
            PageNo:1,
            PageSize: 10,
            State: '',
            SendEventType: '',
            StartTime: '',
            EndTime: ''
        },
        _init:function(){
            this.auto();
        },
        auto:function(){
           var obj = this;
        //获取管理员列表
            var table = $("#staff_List").dataTable({
                ajax : function(data,callback,ettisngs){//ajax配置为function,手动调用异步查询
                    console.log(data.start);
                    obj.page.PageNo =  (data.start /data.length) + 1;
                    obj.page.PageSize = data.length;
                    $.ajax({
                        type : "post",
                        url : "/marketing/sms-record-get-list",
                        cache : false, //禁用缓存
                        data : obj.page, //传入已封装的参数
                        dataType : "json",
                        success : function(res) {
                            //封装返回数据，这里仅演示了修改属性名
                            var returnData = {};
                            returnData.recordsTotal = res.TotalCounts;
                            returnData.recordsFiltered = res.TotalCounts;//后台不实现过滤功能，每次查询均视作全部结果
                            returnData.data = res.Models;
                            //关闭遮罩
                            //$wrapper.spinModal(false);
                            //调用DataTables提供的callback方法，代表数据已封装完成并传回DataTables进行渲染
                            //此时的数据需确保正确无误，异常判断应在执行此回调前自行处理完毕
                            callback(returnData);


                        },
                        error : function(
                            XMLHttpRequest,
                            textStatus,
                            errorThrown) {
                            $
                                .alert("查询失败");

                        }
                    });
                },
                'serverSide':true,
                "pageLength": 10,
                'bPaginate': true,
                'sPaginationType':'full_numbers',
                "bDestory": true,
                "bRetrieve": true,
                "bFilter":false,
                "bSort": true,
                "bProcessing": true, //服务器端进行分页处理
                "autoWidth": false,
                "searching":true,
                "aoColumns": [
                    {"mDataProp": "SmsMessageId",
                        "fnCreatedCell": function (nTd, sData, oData, iRow, iCol) {
                            $(nTd).html(iRow+1);
                        }
                    },
                    {"mDataProp": "Phones"},
                    {"mDataProp": "Content"},
                    {"mDataProp": "SendSuccessCount"},
                    {"mDataProp": "SendEventTypeName"},
                    {"mDataProp": "StateName"},
                    { "mDataProp": "SendTime",
                        "fnCreatedCell": function (nTd, sData, oData, iRow, iCol) {
                            $(nTd).html(m.formatTimeAll2(oData.SendTime));
                        }},
                ],
                "order": [[0, "desc" ]],
                "fnCreatedRow": function (nRow, aData, iDataIndex) {
                    //add selected class
                    $(nRow).click(function () {
                        if ($(this).hasClass('row_selected')) {
                            $(this).removeClass('row_selected');
                        } else {
                            table.$('tr.row_selected').removeClass('row_selected');
                            $(this).addClass('row_selected');
                        }
                    });
                },
                "fnInitComplete": function (oSettings, json) {
                }
            });


        }
    }
    var a = new Cont();


})



